<!--
 * @Description: 
 * @Author: YWJ
 * @Date: 2025-03-24 17:14:55
 * @LastEditors: YWJ
-->
<template>
  <div></div>
</template>

<script setup>
// import { ref, reactive, toRefs, onMounted} from 'vue'
const reactive = (obj) => {
  return createReactive(obj);
};
function shallowReactive(obj) {
  return createReactive(obj, true);
}

const createReactive = (obj, isShallow = false) => {
  return new Proxy(obj, {
    get(target, key, receiver) {
      if (key === "raw") {
        return target;
      }

      track(target, key);
      // 得到原始值结果
      const res = Reflect.get(target, key, receiver);
      if (isShallow) {
        return res;
      }
      if (typeof res === "object" && res !== null) {
        // 调用 reactive 将结果包装成响应式数据并返回
        return reactive(res);
      }
      return res;
    },
    // 省略其他拦截函数
  });
};
// const reactive = (obj) => {
//   return new Proxy(obj, {
//     get(target, key, receiver) {
//       if (key === "raw") {
//         return target;
//       }

//       track(target, key);
//       // 得到原始值结果
//       const res = Reflect.get(target, key, receiver);
//       if (typeof res === "object" && res !== null) {
//         // 调用 reactive 将结果包装成响应式数据并返回
//         return reactive(res);
//       }
//       return Reflect.get(target, key, receiver);
//     },
//     // 省略其他拦截函数
//   });
// };
</script>
<style lang="scss" scoped></style>
